package data

import (
	"errors"
	"io/ioutil"
	"path"
)

func GetImagePath(id string) (string, error) {
	const FolderPath = "/home/sftp_root/shared/IMAGES"
	files, err := ioutil.ReadDir(FolderPath)
	if err != nil {
		return "", err
	}
	for _, file := range files {
		if !file.IsDir() && file.Name()[:(len(id))] == id {
			return path.Join(FolderPath, file.Name()), nil
		}
	}
	return "", errors.New("file not found")
}
